/*
package com.xsd.awen.utils;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import com.xsd.awen.domain.vo.database.DatabaseVo;

import java.sql.SQLException;

public class DataSourceUtils {


    public static DruidPooledConnection getConnection(DruidDataSource dds) throws SQLException {
        return dds.getConnection();
    }

    public static void closeConnection(DruidPooledConnection conn) throws SQLException {
        conn.close();
    }

    public static DruidDataSource createDataSource(DatabaseVo vo) throws SQLException {
        DruidDataSource dds = new DruidDataSource();
        dds.setDriverClassName(vo.getDriverClassName());
        dds.setUrl(vo.getUrl());
        dds.setUsername(vo.getUsername());
        dds.setPassword(vo.getPassword());
        dds.setInitialSize(5);
        dds.setMinIdle(5);
        dds.setMaxActive(20);
        dds.setMaxWait(60000);
        dds.setTimeBetweenEvictionRunsMillis(60000);
        dds.setMinEvictableIdleTimeMillis(300000);
        dds.setMaxEvictableIdleTimeMillis(500000);
        dds.setValidationQuery("select 1");
        dds.setTestWhileIdle(true);
        dds.setTestOnBorrow(false);
        dds.setTestOnReturn(false);
        dds.setKeepAlive(true);
        dds.setPhyMaxUseCount(500);
        dds.setFilters("stat");
        return dds;
    }

    public static boolean closeDataSource(DruidDataSource dds){
        boolean success = true;
        try {
            dds.close();
            if( !dds.isClosed() ){
                Thread.sleep(100);
                dds.close();
            }
        } catch (Throwable e) {
            try {
                Thread.sleep(100);
                dds.close();
                if( !dds.isClosed() ){
                    Thread.sleep(100);
                    dds.close();
                }
            } catch (Throwable e2) {
                success = false;
                e2.printStackTrace();
            }
        }
        return success;
    }

}
*/
